import * as x from './data';
const path = '/';
module.exports = r => {
    r.get(path,
        ctx =>
            x.get(ctx.query).then(ctx.done, ctx.fail)
    ).post(path,
        ctx =>
            x.save(ctx.req.body)
                .then((d) => {
                    ctx.done(d.id);
                }, ctx.fail)
    ).put(path,
        ctx =>
            x.save(ctx.req.body)
                .then(() => {
                    ctx.done();
                }, ctx.fail)
    ).delete(path + '/:id',
        ctx =>
            x.del(ctx.params.id).then(ctx.done, ctx.fail)
    );
};
